﻿<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>南京化工职业技术学院资源共享平台</title>
<link href="<%=basePath%>res/css/css.css" type="text/css" rel="stylesheet" />
<script type="text/javascript">
	function checkUpload() {
		if(${user == null}) {
			alert("请在登录后上传文件！");
			<%
				//0 is default share type
				session.setAttribute("shareType", "0");
			%>
			window.location.href="<%=basePath%>login.jsp?refreshurl=upload.jsp";
		} else {
			window.location.href="<%=basePath%>upload.jsp";
		}
	}
	function skipPage(value) {
		if(value <= 0) {
			alert("当前为第一页！");
			return;
		}
		if(value > document.getElementById("pageBean.totalPage").value) {
			alert("当前为最后一页！");
			return;
		}
		document.getElementById("pageBean.currPage").value = value;
		document.forms[1].submit();
	}
	function changest(value) {
		if(value == 0) {
			document.getElementById("rn").style.fontWeight="bold";
			document.getElementById("rp").style.fontWeight="";
		}
		if(value == 1) {
			document.getElementById("rp").style.fontWeight="bold";
			document.getElementById("rn").style.fontWeight="";
		}
		var querytype = document.getElementById("querytype");
		querytype.value = value;
	}
	function search() {
		var query = document.getElementById("querytype");
		if(query.value == null || query.value == "") {
			alert("请填写搜索条件！");
			return false;
		}
		return true;
	}
	function onload() {
		var defaultQueryType = ${querytype};
		if(defaultQueryType == 0) {
			document.getElementById("rn").style.fontWeight="bold";
			document.getElementById("rp").style.fontWeight="";
		}
		if(defaultQueryType == 1) {
			document.getElementById("rp").style.fontWeight="bold";
			document.getElementById("rn").style.fontWeight="";
		}
	}
	function download(id) {
		if(confirm("确定要下载该资源吗？")) {
			window.location.href="<%=basePath%>njcc/download.action?id=" + id;
		}
	}
</script>
</head>
<body onload="javascript:onload();">
<div id="header">
   <div id="top">
		<ul>
		  <li><marquee onmouseover=this.stop() onmouseout=this.start()>今日访问：${accessCount }&nbsp;&nbsp;共享资源总数：${resCount }&nbsp;&nbsp;注册用户总数：${userCount }&nbsp;&nbsp;资源共享达人：${daUser.realName }&nbsp;&nbsp;资源下载热度：${faRes.name }</marquee></li>
		</ul>
   </div>
   <div id="bottom">
       <div id="bleft"><img src="<%=basePath%>res/images/share_05.jpg" width="387" height="65" />
       </div>
       <div id="bright">
            <ul>
            	<c:if test="${empty user}">
                 <li><a href="javascript:window.location.href='<%=basePath%>login.jsp?refreshurl=entry.jsp';"><img src="<%=basePath%>res/images/share_08.jpg" width="31" height="18" /></a>&nbsp;&nbsp;
                 	<a href="javascript:window.location.href='<%=basePath%>register.jsp?refreshurl=entry.jsp';"><img src="<%=basePath%>res/images/share_1.jpg" width="31" height="18" /></a>&nbsp;&nbsp;
                 	<a href="javascript:window.location.href='<%=basePath%>retrieve.jsp';">忘记密码？</a>
                 </li>
                 </c:if>
            	<c:if test="${!empty user}">
                 <li>
                 	<h2>${user.realName }，欢迎回来！</h2><h2><a href="<%=basePath%>human.jsp" style="color:red;">个人中心，</a></h2>&nbsp;&nbsp;<h2><a href="<%=basePath%>njcc/logout.action">点击退出！</a></h2>
                 </li>
                 </c:if>
            </ul>
       </div>
   </div>
</div>
<div id="content">
     <div id="cleft">
          <div id="sc"><a href="javascript:checkUpload();"><img src="<%=basePath%>res/images/share_03.jpg" width="192" height="58" /></a>
          </div>
          <div id="dh">
                <div id="dhtop"></div>
                <div id="dhc">
                    <ul>
                    	<c:choose>
                    		<c:when test="${empty types}">
                        		<h1 class="font1">暂无数据</h1>
                    		</c:when>
                    		<c:otherwise>
                    			<c:forEach items="${types}" var="typesObj" varStatus="i">
                    				<div style="height:10px;"></div>
                        			<h1 class="font1"><a href="<%=basePath%>njcc/loadRes.action?type=${typesObj.id }">${typesObj.name }</a></h1>
                        			<c:if test="${i.index == 0}">
                        				<c:choose>
				                    		<c:when test="${empty typelist1}">
				                        		<li class="font1">暂无数据</li>
				                    		</c:when>
				                    		<c:otherwise>
				                    			<c:forEach items="${typelist1}" var="typelist1Obj" varStatus="j">
				                    				<c:if test="${j.index % 2 == 0}">
				                    					<li><div style="width:60px;float:left;"><a href="<%=basePath%>njcc/loadRes.action?type=${typelist1Obj.id }">${typelist1Obj.name }</a></div>|
				                    				</c:if>
				                    				<c:if test="${j.index % 2 != 0}">
				                    					<div style="width:60px;float:right;padding-right:20px;"><a href="<%=basePath%>njcc/loadRes.action?type=${typelist1Obj.id }">${typelist1Obj.name }</a></li>
				                    				</c:if>
				                    			</c:forEach>
				                    		</c:otherwise>
                        				</c:choose>
                        			</c:if>
                        			<c:if test="${i.index == 1}">
                        				<c:choose>
				                    		<c:when test="${empty typelist2}">
				                        		<li class="font1">暂无数据</li>
				                    		</c:when>
				                    		<c:otherwise>
				                    			<c:forEach items="${typelist2}" var="typelist1Obj" varStatus="j">
				                    				<c:if test="${j.index % 2 == 0}">
				                    					<li><div style="width:60px;float:left;"><a href="<%=basePath%>njcc/loadRes.action?type=${typelist1Obj.id }">${typelist1Obj.name }</a></div>|
				                    				</c:if>
				                    				<c:if test="${j.index % 2 != 0}">
				                    					<div style="width:60px;float:right;padding-right:20px;"><a href="<%=basePath%>njcc/loadRes.action?type=${typelist1Obj.id }">${typelist1Obj.name }</a></li>
				                    				</c:if>
				                    			</c:forEach>
				                    		</c:otherwise>
                        				</c:choose>
                        			</c:if>
                        			<c:if test="${i.index == 2}">
                        				<c:choose>
				                    		<c:when test="${empty typelist3}">
				                        		<li class="font1">暂无数据</li>
				                    		</c:when>
				                    		<c:otherwise>
				                    			<c:forEach items="${typelist3}" var="typelist1Obj" varStatus="j">
				                    				<c:if test="${j.index % 2 == 0}">
				                    					<li><div style="width:60px;float:left;"><a href="<%=basePath%>njcc/loadRes.action?type=${typelist1Obj.id }">${typelist1Obj.name }</a></div>|
				                    				</c:if>
				                    				<c:if test="${j.index % 2 != 0}">
				                    					<div style="width:60px;float:right;padding-right:20px;"><a href="<%=basePath%>njcc/loadRes.action?type=${typelist1Obj.id }">${typelist1Obj.name }</a></li>
				                    				</c:if>
				                    			</c:forEach>
				                    		</c:otherwise>
                        				</c:choose>
                        			</c:if>
                        			<c:if test="${i.index == 3}">
                        				<c:choose>
				                    		<c:when test="${empty typelist4}">
				                        		<li class="font1">暂无数据</li>
				                    		</c:when>
				                    		<c:otherwise>
				                    			<c:forEach items="${typelist4}" var="typelist1Obj" varStatus="j">
				                    				<c:if test="${j.index % 2 == 0}">
				                    					<li><div style="width:60px;float:left;"><a href="<%=basePath%>njcc/loadRes.action?type=${typelist1Obj.id }">${typelist1Obj.name }</a></div>|
				                    				</c:if>
				                    				<c:if test="${j.index % 2 != 0}">
				                    					<div style="width:60px;float:right;padding-right:20px;"><a href="<%=basePath%>njcc/loadRes.action?type=${typelist1Obj.id }">${typelist1Obj.name }</a></li>
				                    				</c:if>
				                    			</c:forEach>
				                    		</c:otherwise>
                        				</c:choose>
                        			</c:if>
                        			<c:if test="${i.index == 4}">
                        				<c:choose>
				                    		<c:when test="${empty typelist5}">
				                        		<li class="font1">暂无数据</li>
				                    		</c:when>
				                    		<c:otherwise>
				                    			<c:forEach items="${typelist5}" var="typelist1Obj" varStatus="j">
				                    				<c:if test="${j.index % 2 == 0}">
				                    					<li><div style="width:60px;float:left;"><a href="<%=basePath%>njcc/loadRes.action?type=${typelist1Obj.id }">${typelist1Obj.name }</a></div>|
				                    				</c:if>
				                    				<c:if test="${j.index % 2 != 0}">
				                    					<div style="width:60px;float:right;padding-right:20px;"><a href="<%=basePath%>njcc/loadRes.action?type=${typelist1Obj.id }">${typelist1Obj.name }</a></li>
				                    				</c:if>
				                    			</c:forEach>
				                    		</c:otherwise>
                        				</c:choose>
                        			</c:if>
                    			</c:forEach>
                    		</c:otherwise>
                    	</c:choose>
                  </ul>
                </div>
                <div id="dhbottom"><img src="<%=basePath%>res/images/left_08.jpg" width="192" height="16" />
                </div>
          </div>
     <div id="pm">
                <div id="dhtop"><img src="<%=basePath%>res/images/share_10.jpg" width="192" height="64" /></div>
                <div id="pmc" style="background:#eff8fe;">
                    <ul>
                    	<c:choose>
                    		<c:when test="${empty favRes}">
                    			暂无数据
                    		</c:when>
                    		<c:otherwise>
                    			<c:forEach items="${favRes}" var="favResObj" varStatus="i">
                        			<li><div style="float:left;width:20px;">${i.index+1 }、</div>
                        			<div style="float:left;width:120px;">
		                                              	<c:choose>
		                                              		<c:when test="${fn:length(favResObj.info.name) > 20}">
		                                              			<a href="<%=basePath%>njcc/loadResItem.action?id=${favResObj.info.id }">${fn:substring(favResObj.info.name,0,8)}</a>
		                                              		</c:when>
		                                              		<c:otherwise>
		                                              			<a href="<%=basePath%>njcc/loadResItem.action?id=${favResObj.info.id }">${favResObj.info.name }</a>
		                                              		</c:otherwise>
		                                              	</c:choose>
                        			</div>
                        			${favResObj.info.downloadCount }次</li>
                    			</c:forEach>
                    		</c:otherwise>
                    	</c:choose>
                    </ul>
                </div>
                <div id="dhbottom"><img src="<%=basePath%>res/images/share_12.jpg" width="192" height="16" />
                </div>
       </div>
     </div>
  <div id="cright">
                <div id="sarch">
                      <ul>
                            <li class="font1" style="padding-top:10px;"><a href="javascript:changest(0);" id="rn" style="font-weight:bold;">资源名称</a>&nbsp;&nbsp;|&nbsp;&nbsp;<a href="javascript:changest(1);" id="rp">分享人</a></li>
                            <li style="padding-top:10px;">
                            	<form action="<%=basePath%>njcc/search.action" method="post" onsubmit="javascript:return search();">
                            		<table>
                            			<tr>
                            				<td>
	                            				<input type="hidden" name="querytype" id="querytype" value="0"/>
	                            				<input type="text" name="query" id="query" class="inputs" value="${query }"/>
                            				</td>
                            				<td  style="padding-left:10px;">
	                            				<input name="search" value="" type="submit" class="buttons" />
                            				</td>
                            			</tr>
	                            	</table>
                            	</form>
                        	</li>
                      </ul>
    </div>
                	<div id="location"><a class="blue" href="<%=basePath%>">首页</a>
				                		<span class="blue"> >> </span><a class="blue" href="javascript:void(0);" title="${query }">${query }</a>
				       </div>

<!--全部资源 end-->
<form action="<%=basePath%>njcc/search.action?querytype=${querytype }" method="post">
			 <div id="all-source">
                	<!-- <p><strong class="list-titleqb">全部资源</strong></p> -->
	    <table class="table-1" cellspacing=0>
						<thead>
							<tr>
								<td class="td-1"><strong>分类</strong></td>
								<td class="td-2" colspan="2"><strong>名称</strong></td>
								<td class="td-3"><strong>上传用户</strong></td>
								<td class="td-4"><strong>上传时间</strong></td>
								<td class="td-4"><strong>所需积分</strong></td>
								<td class="td-4"><strong>详情</strong></td>
								<td class="td-4"><strong>操作</strong></td>
							</tr>
						</thead>
						<tbody>
							<c:choose>
								<c:when test="${empty reslist}">
									<tr>
										<td colspan="4"></td>
									</tr>
								</c:when>
								<c:otherwise>
									<c:forEach items="${reslist}" var="res">
										<tr>
										    <td class="td-1" title="${res.typeName }">[${res.typeName }]</td>
											<td class="td-0" valign="top">&nbsp;</td>
				                            <td class="td-2"><div class="div_td2" title="${res.info.name }">${fn:substring(res.info.name, 0, 12) }</div></td>
				                            <td class="td-3"><a href="javascript:void(0);" >${res.userName }</a></td>
				                            <td class="td-4">${res.uploadTime }</td>
				                            <td class="td-4">${res.info.reqPoint }</td>
				                            <td class="td-3"><a href="<%=basePath%>njcc/loadResItem.action?id=${res.info.id }" >详情</a></td>
				                            <td class="td-4"><a href="javascript:download(${res.info.id });">下载</a></td>
										</tr>
									</c:forEach>
								</c:otherwise>
							</c:choose>
						</tbody>
					</table>
	</div>
    <div class="pager">
    
							<s:if test="pageBean == null">
							</s:if>
							<s:else>
								<input type="hidden" id="query" name="query" value="${query}" />
								<input type="hidden" id="pageBean.currPage" name="pageBean.currPage" value="${pageBean.currPage}" />
								<input type="hidden" id="pageBean.totalPage" name="pageBean.totalPage" value="${pageBean.totalPage}" />
								<a href="javascript:skipPage(${pageBean.currPage - 1 });">上一页</a>&nbsp;&nbsp;
								第
								<select id="currPage" name="currPage" onchange="javascript:skipPage(this.value);">
									<c:if test="${pageBean.totalPage eq 0}">
										<option value="1">1</option>
									</c:if>
									<c:forEach begin="1" end="${pageBean.totalPage }" step="1"
											var="pageNum">
											<option value="${pageNum}"  <c:if test="${pageBean.currPage == pageNum }"> selected="selected"</c:if>>${pageNum}</option>
									</c:forEach>
								</select>
								页
								<a href="javascript:skipPage(${pageBean.currPage + 1 });">下一页</a>&nbsp;&nbsp;
								共
								<c:choose>
									<c:when test="${pageBean.totalPage eq 0}">
										1
									</c:when>
									<c:otherwise>
										${pageBean.totalPage}
									</c:otherwise>
								</c:choose>
								页
							</s:else>
    </div>
</form>
			</div>
  </div>
<div id="guanggao1" style="margin-bottom:5px;"><img src="<%=basePath%>res/images/share_44.jpg" width="900" height="95" /></div>
<div id="banquan">
           <ul>
                 <li>南京化工职业技术学院--资源共享网 <img src="<%=basePath%>res/images/pic.gif" width="50" height="12" /></li>           
                 <li>诚聘英才 | 友情链接 | 联系我们</li> 
                 <li>版权所有©南京化工职业技术学院 ICP：沪B2-20030192 </li>
  </ul>
</div>
</body>
</html>
